﻿using System;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace BoxApp1
{
    public class Tile
    {
        public Image Sprite { get; set; }
      
        public string TileType { get; set; }

        public bool IsWalkable { get; set; }

        public Tile(string TileType)
        {
           ChangeTile(TileType);
        }

        public void ChangeTile(string type)
        {
            TileType = type;
            Uri uri = null;
            string path = "pack://application:,,,/Resources/Sprites/";
            switch (TileType)
            {
                case "W":
                    IsWalkable = false;
                    uri = new Uri(path + "wall.jpg");
                    break;
                case "P":
                    IsWalkable = true;
                    uri = new Uri(path + "empty.jpg");
                    break;
                case "G":
                    IsWalkable = true;
                    uri = new Uri(path + "goal.jpg");
                    break;
                case "B":
                    IsWalkable = false;
                    uri = new Uri(path + "box.jpg");
                    break;
                default:
                    IsWalkable = true;
                    uri = new Uri(path + "empty.jpg");
                    break;
            }
            var bitmap = new BitmapImage(uri);
            Sprite = new Image();
            Sprite.Source = bitmap;
        }
    }
}
